<?php
require_once 'common.php';

// 获取分段时间列表
$times = getTimes();

$game = $_REQUEST['game'];
$game = $_REQUEST['platform'];
$game = $_REQUEST['game'];
$date = $_REQUEST['date'];
if(!$date) {
	$date = date('Y-m-d');
}

function getNowHour() {
	$hour = date('H:i');
	$arr = explode(":", $hour);
	if($arr[1] < 15) {
		$arr[1] = 00;
	} else if($arr[1] >= 15 && $arr[1] < 30) {
		$arr[1] = 15;
	} else if($arr[1] >= 30 && $arr[1] < 45) {
		$arr[1] = 30;
	} else if($arr[1] >= 45 && $arr[1] <= 59) {
		$arr[1] = 45;
	}
	
	$hour = implode(':',$arr) . ":00";
	return $hour;
}

function getTimes() {
	// 间隔15分钟
	$stepTime = 15 * 60;
	
	$date = date("Y-m-d");
	
	$hour = getNowHour();
	
	// 今天凌晨时间戳
	$todayStrTime = strtotime($date);
	// 现在时间
	$nowStrTime = strtotime($date . " " . $hour);
	
	$minusStrTime = $nowStrTime - $todayStrTime;
	
	$steps = $minusStrTime/$stepTime;
	
	$times = array();
	$timesView = array(); // H:s
	for ($i = 0; $i <= $steps; $i++) {
		$time = $todayStrTime + $i * $stepTime;
		$times[] = date('H:i:s', $time);
		$timesView[] = date('H:i', $time);
	}
	return $times;
}
